<template>
  <div>
    <el-form ref="heatmapSetting" :model="setting" label-position="top">
      <el-form-item :label="$t('custom.component.gadget.lineTitle')">
        <el-input v-model="setting.title" :placeholder="$t('custom.component.gadget.lineTitlePlaceholder')"></el-input>
      </el-form-item>
      <el-form-item :label="$t('custom.component.gadget.dimension')">
        <el-select v-model="setting.dimension" style="width: 100%">
          <el-option v-for="item in fieldsList" :label="item.name" :value="item.name" :key="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('custom.component.gadget.dimensionName')">
        <el-input v-model="setting.dimensionName"></el-input>
      </el-form-item>
      <el-form-item :label="$t('custom.component.gadget.measure')">
        <el-select v-model="setting.measure" style="width: 100%">
          <el-option v-for="item in fieldsList" :label="item.name" :value="item.name" :key="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('custom.component.gadget.measureName')">
        <el-input v-model="setting.measureName"></el-input>
      </el-form-item>
      <el-form-item :label="$t('custom.component.gadget.label')">
        <el-select v-model="setting.label" style="width: 100%">
          <el-option v-for="item in fieldsList" :label="item.name" :value="item.name" :key="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('custom.component.gadget.tooltipName')">
        <el-input v-model="setting.tooltipName"></el-input>
      </el-form-item>
      <el-form-item :label="$t('custom.component.gadget.showLabel')">
        <el-checkbox v-model="setting.showLabel">Show Label</el-checkbox>
      </el-form-item>
      <el-form-item :label="$t('custom.component.gadget.minValue')">
        <el-input v-model="setting.minValue"></el-input>
      </el-form-item>
      <el-form-item :label="$t('custom.component.gadget.maxValue')">
        <el-input v-model="setting.maxValue"></el-input>
      </el-form-item>
      <el-form-item :label="$t('custom.component.gadget.orient')">
        <el-select v-model="setting.orient" style="width: 100%">
          <el-option label="horizontal" value="horizontal"></el-option>
          <el-option label="vertical" value="vertical"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('custom.component.gadget.gridTop')">
        <el-input v-model="setting.gridTop"></el-input>
      </el-form-item>
      <el-form-item :label="$t('custom.component.gadget.leftSideDistance')">
        <el-select v-model="setting.leftSideDistance" style="width: 100%">
          <el-option label="left" value="left"></el-option>
          <el-option label="center" value="center"></el-option>
          <el-option label="right" value="right"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('custom.component.gadget.bottomSideDistance')">
        <el-input v-model="setting.bottomSideDistance"></el-input>
      </el-form-item>
      <el-form-item :label="$t('custom.component.gadget.istotal')">
         <el-switch v-model="setting.isTotal"></el-switch>
      </el-form-item>
      <el-form-item :label="$t('custom.component.gadget.color')">
        <el-color-picker
            size="small"
            v-model="setting.color[0]"
            :predefine="predefineColors">
        </el-color-picker>
        <el-color-picker
            size="small"
            v-model="setting.color[1]"
            :predefine="predefineColors">
        </el-color-picker>
        <el-color-picker
            size="small"
            v-model="setting.color[2]"
            :predefine="predefineColors">
        </el-color-picker>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

export default {
  name: 'heatmapSetting',
  components: { },
  data () {
    return {
      setting: {
        title: null,
        dimension: null,
        dimensionName: null,
        measure: null,
        measureName: null,
        label: null,
        labelName: null,
        tooltipName: null,
        showLabel: true,
        minValue: null,
        maxValue: null,
        orient: 'horizontal',
        gridTop: '10%',
        leftSideDistance: 'center',
        bottomSideDistance: '10',
        isTotal: false,
        color: ['#e60d00', '#dbe182', '#008000']
      },
      predefineColors: [
        '#ff4500',
        '#ff8c00',
        '#ffd700',
        '#90ee90',
        '#00ced1',
        '#1e90ff',
        '#c71585'
      ]
    }
  },
  props: [
    'data', 'fieldsList'
  ],
  watch: {
    data (value, oldValue) {
      return this.updateSetting(value)
    },
  },
  computed: { },
  created () {
    if (this.data) {
      this.$set(this.data)
    }
  },
  methods: {
    getData () {
      return this.setting
    },
    updateSetting (value, list, layerStatus) {
      this._.merge(this.setting, value.gadgetSetting)
      this.$emit('update:data', this.setting)
    }

  }
}
</script>

<style lang="scss">
.line-setting {

}

</style>
